clc
clear
close all
% tf = 1460s
% F1
F1 = load('F1.mat');
time1 = F1.t;
V1 = F1.state(:, 4)*F1.Vs;
alt1 = (F1.state(:, 1) - 1)*F1.R0/1000;
alpha1 = F1.ctrl(:, 1)*180/pi;
absBank1 = F1.ctrl(:, 2)*180/pi;
signOfBank1 = F1.ctrl(:, 3);
bank1 = absBank1.*signOfBank1;
lon1 = F1.state(:, 2)*180/pi;
lat1 = F1.state(:, 3)*180/pi;
path1 = F1.path;
% F2
F2 = load('F2.mat');
time2 = F2.t;
V2 = F2.state(:, 4)*F2.Vs;
alt2 = (F2.state(:, 1) - 1)*F2.R0/1000;
alpha2 = F2.ctrl(:, 1)*180/pi;
absBank2 = F2.ctrl(:, 2)*180/pi;
signOfBank2 = F2.ctrl(:, 3);
bank2 = absBank2.*signOfBank2;
lon2 = F2.state(:, 2)*180/pi;
lat2 = F2.state(:, 3)*180/pi;
path2 = F2.path;
% F3
F3 = load('F3.mat');
time3 = F3.t;
V3 = F3.state(:, 4)*F3.Vs;
alt3 = (F3.state(:, 1) - 1)*F3.R0/1000;
alpha3 = F3.ctrl(:, 1)*180/pi;
absBank3 = F3.ctrl(:, 2)*180/pi;
signOfBank3 = F3.ctrl(:, 3);
bank3 = absBank3.*signOfBank3;
lon3 = F3.state(:, 2)*180/pi;
lat3 = F3.state(:, 3)*180/pi;
path3 = F3.path;

f = figure('Name', '地面轨迹');
plot(lon1, lat1, lon2, lat2, '-.', lon3, lat3, '--', 'linewidth', 1.5);
xlabel('经度/(deg)'); ylabel('纬度/(deg)');
legend('飞行器1', '飞行器2', '飞行器3','Location','northwest');
legend('boxoff');
saveas(f, f.Name, 'svg')

f = figure('Name', '高度-时间历程');
plot(time1, alt1, time2, alt2, '-.', time3, alt3,  '--', 'linewidth', 1.5);
xlabel('时间/s'); ylabel('高度/km');
legend('飞行器1', '飞行器2', '飞行器3','Location','northeast');legend('boxoff');
saveas(f, f.Name, 'svg')

f = figure('Name', '攻角-时间历程');
plot(time1, alpha1, time2, alpha2, '-.', time3, alpha3,  '--', 'linewidth', 1.5);
xlabel('时间/s'); ylabel('攻角/(deg)');
legend('飞行器1', '飞行器2', '飞行器3','Location','northeast');legend('boxoff');
saveas(f, f.Name, 'svg')

f = figure('Name', '倾侧角-时间历程');
plot(time1, bank1, time2, bank2, '-.', time3, bank3,  '--', 'linewidth', 1.5);
xlabel('时间/s'); ylabel('倾侧角/(deg)');
legend('飞行器1', '飞行器2', '飞行器3','Location','northeast');legend('boxoff');
saveas(f, f.Name, 'svg')

f = figure('Name', '热流、过载、动压-时间历程');
subplot(3,1,1)
plot(time1(2:end), path1(:,1), time2(2:end), path2(:,1), '-.', time3(2:end), path3(:,1),  '--', 'linewidth', 1.5);
ylabel("热流/(kW·m^2）");
subplot(3,1,2)
plot(time1(2:end), path1(:,2), time2(2:end), path2(:,2), '-.', time3(2:end), path3(:,2),  '--', 'linewidth', 1.5);
ylabel("过载/g");
subplot(3,1,3)
plot(time1(2:end), path1(:,3)/1e3, time2(2:end), path2(:,3)/1e3, '-.', time3(2:end), path3(:,3)/1e3,  '--', 'linewidth', 1.5);
ylabel("动压/kPa");
xlabel('时间/s');
saveas(f, f.Name, 'svg')